package com.pet.controller.webUser;

import com.pet.dto.web.InvitationInformationDTO;
import com.pet.dto.web.InvitationRemarkDTO;
import com.pet.pageDto.InvitationPageDTO;
import com.pet.result.PageResult;
import com.pet.result.Result;
import com.pet.service.InvitationService;
import com.pet.vo.web.InvitationCollectVO;
import com.pet.vo.web.InvitationHotVO;
import com.pet.vo.web.InvitationInformationVO;
import com.pet.vo.web.InvitationRemarkVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 员工管理
 */
@RestController
@RequestMapping("/user")
@Slf4j
public class InvitationController {

    @Autowired
    private InvitationService invitationService;

    /**
     * 创建帖子
     * @param dto
     * @return
     */
    @PostMapping("/invitationInformation")
    private Result insertInvitationInformation(@RequestBody InvitationInformationDTO dto){
        log.info("创建帖子：{}",dto);
        invitationService.insertInvitationInformation(dto);
        return Result.success();
    }

    /**
     * 查询帖子
     */
    @PostMapping("/invitationAllInformation")
    public Result<PageResult> pageInvitation(@RequestBody InvitationPageDTO dto){
        log.info("查询帖子：{}",dto);
        PageResult pageResult = invitationService.pageQuery(dto);//获得数据总数 将内容分装成集合
        return Result.success(pageResult);
    }

    /**
     * 查询帖子详情
     */
    @GetMapping("/invitationAppointedInfo")
    public Result<InvitationInformationVO> selectInvitationInfoById(@RequestParam Integer id){
        log.info("查询帖子详情");
        return Result.success(invitationService.selectInvitationInfoById(id));
    }

    /**
     * 修改帖子
     */
    @PutMapping("/invitationInformation")
    public Result updateInvitation(@RequestBody InvitationInformationDTO dto){
        log.info("修改帖子:{}",dto);
        invitationService.updateInvitation(dto);
        return Result.success();
    }

    /**
     * 删除帖子
     */
    @DeleteMapping("/invitationInformation")
    public Result deleteInvitation(@RequestParam List<Integer> ids){
        log.info("删除帖子：{}",ids);
        invitationService.deleteInvitation(ids);
        return Result.success();
    }

    /**
     * 为帖子点赞
     */
    @PutMapping("/invitationLike")
    public Result invitationLike(@RequestParam Integer id){
        log.info("帖子点赞");
        invitationService.invitationLike(id);

        return Result.success();
    }

    /**
     * 取消帖子的点赞
     */
    @DeleteMapping("invitationLike")
    public Result invitation(@RequestParam Integer id){
        log.info("取消帖子点赞");
        invitationService.deleteInvitationLike(id);

        return Result.success();
    }

    /**
     * 收藏帖子
     */
    @PostMapping("/invitationCollect")
    public Result invitationCollect(@RequestParam Integer id){
        log.info("收藏帖子");
        invitationService.invitationCollect(id);

        return Result.success();
    }

    /**
     * 取消收藏帖子
     */
    @DeleteMapping("invitationCollect")
    public Result deleteInvitationCollect(@RequestParam Integer invitationId){
        log.info("取消收藏帖子{}",invitationId);
        invitationService.deleteInvitationCollect(invitationId);

        return Result.success();
    }

    /**
     * 查询个人收藏
     */
    @GetMapping("/personalInvitationCollect")
    public Result<List<InvitationCollectVO>> selectInvitationCollectById(){
        log.info("查询个人收藏");

        return Result.success(invitationService.selectInvitationCollectById());
    }

    /**
     * 查询个人喜欢
     */
    @GetMapping("/personalInvitationLike")
    public Result<List<InvitationCollectVO>> selectInvitationLikeById(){
        log.info("查询个人喜欢");

        return Result.success(invitationService.selectInvitationLikeById());
    }

    /**
     * 评论帖子
     */
    @PostMapping("/invitationRemark")
    public Result InsertInvitationRemark(@RequestBody InvitationRemarkDTO invitationRemarkDTO){

        log.info("评论帖子：{}",invitationRemarkDTO);
        invitationService.InsertInvitationRemark(invitationRemarkDTO);
        return Result.success();
    }

    /**
     * 查询是否点赞
     */
    @GetMapping("/invitationRemarkUserLikeStatus")
    public Result<Boolean> invitationRemarkUserLikeStatus(@RequestParam Integer id){

        log.info("查询是否点赞:{}",id);
        Boolean status = invitationService.invitationRemarkUserLikeStatus(id);

        return Result.success(status);
    }

    /**
     * 查询是否收藏
     */
    @GetMapping("/invitationRemarkUserCollectStatus")
    public Result<Boolean> invitationRemarkUserCollectStatus(@RequestParam Integer id){

        log.info("查询是否点赞:{}",id);
        Boolean status = invitationService.invitationRemarkUserCollectStatus(id);

        return Result.success(status);
    }

    /**
     * 查询帖子评论
     */
    @GetMapping("/invitationRemark")
    public Result<List<InvitationRemarkVO>> selectInvitationRemark(@RequestParam Integer invitationId){
        log.info("查询帖子评论:{}",invitationId);
        List<InvitationRemarkVO> invitationRemarkVOList = invitationService.selectInvitationRemark(invitationId);

        return Result.success(invitationRemarkVOList);
    }

    /**
     * 查询热门帖子
     */
    @GetMapping("/invitationHot")
    public Result<List<InvitationHotVO>> selectInvitationHot(){
        log.info("查询热门帖子");
        return Result.success(invitationService.selectInvitationHot());
    }

    /**
     * 查询发表的评论
     */
    @GetMapping("/invitationRemarksSelf")
    public Result<List<InvitationRemarkVO>> selectInvitationRemarksSelf(){

        log.info("查询发表的评论");
        return Result.success(invitationService.selectInvitationRemarksSelf());
    }

    /**
     * 修改发表的评论
     */
    @PostMapping("/invitationRemarksSelf")
    public Result updateInvitationRemarksSelf(@RequestBody InvitationRemarkDTO dto){
        log.info("修改发表的评论:{}",dto);
        invitationService.updateInvitationRemarksSelf(dto);
        return Result.success();
    }

    /**
     * 删除发表的评论
     */
    @DeleteMapping("/invitationRemarksSelf")
    public Result deleteInvitationRemarksSelf(@RequestParam Integer id){
        log.info("删除发表的评论{}",id);
        invitationService.deleteInvitationRemarksSelf(id);
        return Result.success();
    }


}
